<script setup>
const props = defineProps({
  car: {
    type: String,
    default: '奥迪',
  },

  money: {
    type: Number,
    required: true,
  },
})

console.log(props.car, props.money)

// 提前定义将来要出发的自定义事件
const emit = defineEmits(['changeCar']) //emit 直接等价于 this.$emit
const changeCar = () => {
  console.log('换车')
  //通知父组件更新car 奔驰 没有this
  emit('changeCar', '阿斯顿马丁')
}
</script>

<template>
  <div class="son">
    我是子组件--{{ car }}价格{{ money }}
    <button @click="changeCar">换车</button>
    <button @click="emit('spandMoney', 1000)">花钱-100</button>
  </div>
</template>

<style scoped>
.son {
  border: 4px solid #000;
  margin: 10px;
  padding: 50px;
  border-radius: 5px;
}
</style>
